package cn.wolfcode.education.service.impl;

import cn.wolfcode.education.domain.Payroll;
import cn.wolfcode.education.mapper.PayrollMapper;
import cn.wolfcode.education.query.PayrollQuery;
import cn.wolfcode.education.query.QueryObject;
import cn.wolfcode.education.service.IPayrollService;
import cn.wolfcode.education.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Service
public class PayrollServiceImpl implements IPayrollService {

    @Autowired
    private PayrollMapper payrollMapper;

    //分页,列表
    public PageResult queryAll(QueryObject qo) {
        int total = payrollMapper.queryForCount(qo);
        if(total == 0){
            return new PageResult();
        }
        List<Payroll> rows = payrollMapper.queryForList(qo);
        return new PageResult(total,rows);
    }
    //更新
    public void update(Payroll payroll) {
        payrollMapper.updateByPrimaryKey(payroll);
    }
    //删除
    public void delete(Long id) {
        payrollMapper.deleteByPrimaryKey(id);
    }

    public List queryForList(PayrollQuery qo) {
        return payrollMapper.queryForList(qo);
    }

    //获取一行的数据
    public Payroll selectByPrimaryKey(Long id) {
        return payrollMapper.selectByPrimaryKey(id);
    }

    public void insertFromFile(Payroll payroll) {
        payrollMapper.insertFromFile(payroll);
    }

    public Payroll selectPrimaryByKey(Long id) {
        return payrollMapper.selectByPrimaryKey(id);
    }
    //结算
    public void updatePayTime(Long id, Date date, BigDecimal bigDecimal) {
        payrollMapper.updatePayTime(id,date,bigDecimal);
    }

}
